package com.shaoshaohuo.app.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.shaoshaohuo.app.R;
import com.shaoshaohuo.app.framework.SharedPreferencesHelper;

import java.text.SimpleDateFormat;
import java.util.Date;

public class FinishPayMoney extends AppCompatActivity implements View.OnClickListener {
    /**
     * tobar
     */
    private ImageView order_tobar_back;
    private TextView order_tobar_enter;
    private ImageView order_tobar_right;
    private LinearLayout order_layout_topbar_left;
    private TextView right_textview_message;

    private TextView finish_pay_order_number;
    private TextView finish_pay_moner_hour;
    private TextView finish_pay_look_order;
    private TextView finish_pay_back_home;
    private Object indate;
    private String format;
    private String orderid;
    private TextView finish_pay_money_hint;
    private String type = "1";
    private String totalmoney;

//    private List<FragmentNewCarEntity.DataBean> sure_order_shop_data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_finish_pay_money);
//        ToastUtil.toast("啥情况");
        getindate();
        initView();
        initListener();
    }

    private void initListener() {
        finish_pay_back_home.setOnClickListener(this);
        finish_pay_look_order.setOnClickListener(this);
        order_tobar_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        right_textview_message.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

//    private void setView() {
//        finish_pay_order_number.setText("9999999999999");
//        finish_pay_moner_hour.setText("12.00.00");
//    }

    private void initView() {
        /**
         * tobar
         * */
        order_layout_topbar_left = (LinearLayout) findViewById(R.id.layout_topbar_left);
        order_layout_topbar_left.setVisibility(View.VISIBLE);
        order_tobar_back = (ImageView) findViewById(R.id.imageview_topbar_left_backImage);
        order_tobar_back.setVisibility(View.VISIBLE);
        order_tobar_back.setImageResource(R.mipmap.return_key);
        order_tobar_enter = (TextView) findViewById(R.id.toolbar_topname);
        order_tobar_enter.setText("支付成功");
        order_tobar_right = (ImageView) findViewById(R.id.imageview_message);
        order_tobar_right.setVisibility(View.GONE);
        right_textview_message = (TextView) findViewById(R.id.textview_message);
        right_textview_message.setText("完成");
        right_textview_message.setVisibility(View.VISIBLE);

        finish_pay_money_hint = (TextView) findViewById(R.id.finish_pay_money_hint);
        finish_pay_order_number = (TextView) findViewById(R.id.finish_pay_order_number);
        finish_pay_moner_hour = (TextView) findViewById(R.id.finish_pay_moner_hour);
        finish_pay_look_order = (TextView) findViewById(R.id.finish_pay_look_order);
        finish_pay_back_home = (TextView) findViewById(R.id.finish_pay_back_home);
        finish_pay_order_number.setText("订单编号:" + orderid);
        finish_pay_moner_hour.setText("付款时间:" + format);

    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch (v.getId()) {
            case R.id.finish_pay_back_home:
                SharedPreferencesHelper sharedPreferencesHelper = new SharedPreferencesHelper();
                sharedPreferencesHelper.setBoolean(this, SharedPreferencesHelper.Field.HOME, true);
                finish();
                break;
            case R.id.finish_pay_look_order:
                intent.setClass(getApplicationContext(), new ShopAllOrderActivity().newInstance(intent, "待发货", 2).getClass());
                startActivity(intent);
//                OrderShopInfoEntity.DataBean orderShopInfoEntity = new OrderShopInfoEntity.DataBean();
//                orderShopInfoEntity.setBuy_num(sure_order_shop_data.get(0).getNum());
//                orderShopInfoEntity.setName(sure_order_shop_data.get(0).getNames());
//                orderShopInfoEntity.setImg(sure_order_shop_data.get(0).getImg());
//                orderShopInfoEntity.setFin_money(sure_order_shop_data.get(0).getPrice());
//                orderShopInfoEntity.setOrderid(sure_order_shop_data.get(0).getOrderid());
//                orderShopInfoEntity.setDetails(sure_order_shop_data.get(0).getDetails());
//                orderShopInfoEntity.setMbn_details(sure_order_shop_data.get(0).getMbn_details() + "");
//                Bundle bundle = new Bundle();
//                bundle.putString("status", "2");
//                bundle.putString("type", "1");
//                bundle.putSerializable("intent_data", orderShopInfoEntity);
//                intent.putExtras(bundle);
                startActivity(intent);
                break;
        }
    }

    public void getindate() {
        Intent intent = getIntent();
//        t.putExtra("time",l);
//        intent.putExtra("orderid",orderid);
        //支付时间
        long time = intent.getLongExtra("time", 0);
        Date date = new Date(time);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        format = simpleDateFormat.format(date);
        //订单号
        orderid = intent.getStringExtra("orderid");
//        sure_order_shop_data = (List<FragmentNewCarEntity.DataBean>) intent.getSerializableExtra("shop_data");
        totalmoney = intent.getStringExtra("totalmoney");
    }
}
